<template>
    <div>
        <el-card v-show="!isToExam" class="box-card" style="width: 100%">
            <div slot="header" class="clearfix">
                <div style="display: flex;justify-content: space-between">
                    <el-input style="width: 200px"></el-input>
                    <el-button style=" padding: 3px 0" type="text" @click="dialogVisible = true">
                        添加报名
                    </el-button>
                </div>
                <el-dialog
                        title="新建报名"
                        :visible.sync="dialogVisible"
                        width="50%"
                        :before-close="handleClose">
                    <register-form @registerForm="get_n_Org" :registerParams="registerParams" style="text-align: left"></register-form>
                </el-dialog>
            </div>
            <div class="register-main">
                <el-card class="model" shadow="hover" v-for="(item,index) in profile" :key="item.id">
                    <div class="myexam-message">
                        <div style="border-bottom: 2px solid black;height: 40px;line-height: 40px;display: flex;justify-content: space-between;align-items: center">
                            <h4>
                                报考科目:{{item.course.name}}</h4>
                            <el-button size="small" @click="updateContent(index)">编辑信息</el-button>
                        </div>
                        <p><i class="el-icon-s-platform"></i>报考机构:<span class="Registertext">{{item.org.org_name}}</span></p>
                        <p><i class="el-icon-user-solid"></i>学员姓名:<span class="Registertext">{{item.name}}</span></p>
                        <p><i class="el-icon-crop"></i>是否购书:<span class="Registertext"><el-tag>{{item.org.is_train == null ? '否':'是'}}</el-tag></span></p>
                        <p><i class="el-icon-copy-document"></i>是否参加课程培训:<span class="Registertext"><el-tag>{{item.is_train ? '是':'否'}}</el-tag></span></p>
                        <p><i class="el-icon-date"></i>激活日期:<span class="Registertext">{{item.active_date}}</span></p>
                        <p><i class="el-icon-pie-chart"></i>账号到期日期:<span class="Registertext">{{item.exp_date}}</span></p>
                        <p><i class="el-icon-s-data"></i>考试城市:<span class="Registertext">{{item.exam_city}}</span></p>
                        <p><i class="el-icon-question"></i>审核状态:<span class="Registertext">{{stateModel[item.state_code]}}</span></p>
                        <div v-if="item.state_code < 3" style="display: flex;justify-content: flex-end;padding-top: 10px">
                            <el-button @click="isToExamFun(index)">点击报考</el-button>
                        </div>
                    </div>
                    <el-drawer
                            size="35%"
                            title="修改信息"
                            :visible.sync="drawer"
                            :direction="direction"
                            :before-close="editHandleClose">
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-row>
                                <el-col :span="7">
                                    <el-form-item label="姓名:">
                                        <el-input v-model="form.name"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="7">
                                    <el-form-item label="姓拼音:">
                                        <el-input v-model="form.first_py"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="7">
                                    <el-form-item label="名拼音:">
                                        <el-input v-model="form.last_py"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="性别:">
                                        <el-radio v-model="form.gender" label="m">男</el-radio>
                                        <el-radio v-model="form.gender" label="f">女</el-radio>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="出生日期:">
<!--                                        <el-input v-model="form.birthday"></el-input>-->
                                        <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                        placeholder="选择日期" v-model="form.birthday"
                                                        style="width: 100%;"></el-date-picker>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="9">
                                    <el-form-item label="证件类型:">
                                        <el-select v-model="form.card_type" placeholder="请选择证件类型">
                                            <el-option v-for="item in cardOptions" :key="item.id" :label="item.name"
                                                       :value="item.id"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="证件号码:">
                                        <el-input v-model="form.card_id"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="手机号码:">
                                        <el-input v-model="form.phone"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="邮箱:">
                                        <el-input v-model="form.email"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="9">
                                    <el-form-item label="现居省份:">
                                        <el-cascader
                                                size="large"
                                                :options="areaOptions"
                                                v-model="selectedOptions"
                                                @change="addressChange">
                                        </el-cascader>
                                    </el-form-item>
                                </el-col>
<!--                                <el-col :span="9">-->
<!--                                    <el-form-item label="现居城市:">-->
<!--                                        <el-input v-model="form.city"></el-input>-->
<!--                                    </el-form-item>-->
<!--                                </el-col>-->
                            </el-row>
                            <el-row>
                                <el-col :span="13">
                                    <el-form-item label="详细地址:">
                                        <el-input v-model="form.address"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="单位名称:">
                                        <el-input v-model="form.com_name"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="毕业学校:">
                                        <el-input v-model="form.school"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="毕业时间:">
                                        <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                        placeholder="选择日期" v-model="form.grad_time"
                                                        style="width: 100%;"></el-date-picker>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="最高学历:">
                                        <el-select v-model="form.hig_edu" placeholder="最高学历">
                                            <el-option label="硕士研究生" value="硕士研究生"></el-option>
                                            <el-option label="博士" value="博士"></el-option>
                                            <el-option label="本科" value="本科"></el-option>
                                            <el-option label="大专" value="大专"></el-option>
                                            <el-option label="中专/职技校" value="中专/职技校"></el-option>
                                            <el-option label="高中" value="高中"></el-option>
                                            <el-option label="其他" value="其他"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="专业门类:">
                                        <el-input v-model="form.major"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="7">
                                    <el-form-item label="从业年限:">
                                        <el-input type="number" v-model="form.work_age"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="现有职称:">
                                        <el-input v-model="form.work_title"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="现有职务:">
                                        <el-input v-model="form.work_duty"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="职务英文:">
                                        <el-input v-model="form.work_duty_en"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="是否购书:">
                                        <el-switch v-model="form.buy_book" active-text="是" inactive-text="否">
                                        </el-switch>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="证件照:">
                                        <el-input v-model="form.photo"></el-input>
<!--                                        <img-upload v-model="form.photo"></img-upload>-->
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
<!--                                    <el-form-item label="激活日期">-->
<!--                                        <el-input v-model="form.active_date"></el-input>-->
<!--                                    </el-form-item>-->
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="10">
                                    <el-form-item label="考试城市">
                                        <el-input v-model="form.exam_city"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10">
                                    <el-form-item label="考试时间">
                                        <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                        placeholder="选择日期" v-model="form.exam_date"
                                                        style="width: 100%;"></el-date-picker>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-form-item>
                                <el-button type="primary" @click="editContent">立即修改</el-button>
                                <el-button @click="editHandleClose">取消</el-button>
                            </el-form-item>
                        </el-form>
                    </el-drawer>
                </el-card>
            </div>
        </el-card>
        <div v-show="isToExam" class="to-exam">
            <el-card class="box-card" style="width: 100%">
                <div slot="header" class="clearfix">
                    <el-page-header @back="toMyExam" :content="examForm.course.name+'--报考信息'">
                    </el-page-header>
                </div>
                <div>
                    <el-form label-position="right" ref="examForm" :rules="rules" label-width="120px" :model="examForm">
                        <el-steps align-center :active="active" finish-status="success">
                            <el-step title="步骤 1"></el-step>
                            <el-step title="步骤 2"></el-step>
                            <el-step title="步骤 3"></el-step>
                        </el-steps>
                        <div style="padding: 20px">
                            <div v-show="active == 1">
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="name" label="姓名:">
                                            <el-input v-model="examForm.name"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="last_py" label="姓拼音:">
                                            <el-input v-model="examForm.last_py"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item prop="first_py" label="名拼音:">
                                            <el-input v-model="examForm.first_py"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item label="证件类型:">
                                            <el-select v-model="examForm.card_type" placeholder="请选择证件类型">
                                                <el-option v-for="item in cardOptions" :key="item.id" :label="item.name"
                                                           :value="item.id"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="9">
                                        <el-form-item label="证件号码:">
                                            <el-input v-model="examForm.card_id"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="9">
                                        <el-form-item label="出生日期:">
                                            <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                            placeholder="选择日期" v-model="examForm.birthday"
                                                            style="width: 100%;"></el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="9">
                                        <el-form-item label="家庭住址:">
                                            <el-input type="textarea" v-model="examForm.address"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="9">
                                        <el-form-item prop="school" label="毕业学校:">
                                            <el-input v-model="examForm.school"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="9">
                                        <el-form-item prop="grad_time" label="毕业时间:">
                                            <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                            placeholder="选择日期" v-model="examForm.grad_time"
                                                            style="width: 100%;"></el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="hig_edu" label="最高学历:">
                                            <el-select v-model="examForm.hig_edu" placeholder="最高学历">
                                                <el-option label="硕士研究生" value="硕士研究生"></el-option>
                                                <el-option label="博士" value="博士"></el-option>
                                                <el-option label="本科" value="本科"></el-option>
                                                <el-option label="大专" value="大专"></el-option>
                                                <el-option label="中专/职技校" value="中专/职技校"></el-option>
                                                <el-option label="高中" value="高中"></el-option>
                                                <el-option label="其他" value="其他"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="9">
                                        <el-form-item prop="major" label="专业门类:">
                                            <el-input v-model="examForm.major"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                            <div v-show="active == 2">
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item label="单位名称:">
                                            <el-input v-model="examForm.com_name"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item prop="work_duty" label="现有职务:">
                                            <el-input v-model="examForm.work_duty"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item label="现有职务英文:">
                                            <el-input v-model="examForm.work_duty_en"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item prop="work_title" label="现有职称:">
                                            <el-input v-model="examForm.work_title"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="work_age" label="从业年限:">
                                            <el-input type="number" v-model="examForm.work_age"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                            <div v-show="active == 3">
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item label="机构代码:">
                                            <el-input v-model="examForm.org.org_code"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <!--                                    <el-col :span="8">-->
                                    <!--                                        <el-form-item prop="course" label="考试级别:">-->
                                    <!--                                            <el-input v-model="examForm.course.id"></el-input>-->
                                    <!--                                        </el-form-item>-->
                                    <!--                                    </el-col>-->
                                    <el-col :span="9">
                                        <el-form-item prop="exam_date" label="考试时间:">
                                            <el-date-picker format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd"
                                                            placeholder="选择日期" v-model="examForm.exam_date"
                                                            style="width: 100%;"></el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="exam_city" label="考试城市:">
                                            <el-input v-model="examForm.exam_city"></el-input>
<!--                                            <el-select v-model="value" placeholder="请选择">-->
<!--                                                <el-option-->
<!--                                                        v-for="item in examCityOption"-->
<!--                                                        :key="item.value"-->
<!--                                                        :label="item.label"-->
<!--                                                        :value="item.value">-->
<!--                                                </el-option>-->
<!--                                            </el-select>-->
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item style="text-align: left" label="是否参加培训:">
                                            <el-switch
                                                    v-model="examForm.is_train"
                                                    active-color="#13ce66">
                                            </el-switch>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col>
                                        <el-form-item label="证件照:">
<!--                                            <card-upload ref="cardUpload"></card-upload>-->
                                            <img-upload @upload="upload"></img-upload>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col>
                                        <el-form-item label="电子签名:">
                                            <el-input v-model="examForm.sign"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item prop="phone" label="手机号码:">
                                            <el-input v-model="examForm.phone"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="10">
                                        <el-form-item prop="code" label="短信验证码">
                                            <div style="display: flex;">
                                                <el-input v-model="examForm.code"></el-input>
                                                <el-button>
                                                    <tencent-captcha :phone-rule="true" :phone="examForm.phone"
                                                                     scene="1"></tencent-captcha>
                                                </el-button>
                                            </div>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                        </div>
                    </el-form>
                    <el-button v-if="active > 1 && active < 4" style="margin-top: 12px;" @click="pre">上一步</el-button>
                    <el-button v-if="active < 3" style="margin-top: 12px;" @click="next">下一步</el-button>
                    <el-button v-if="active == 3" style="margin-top: 12px;" @click="examReg">提交</el-button>
                </div>
            </el-card>
        </div>
    </div>
</template>

<script>
    import {courselist} from "../../../request/api";
    import {provinceAndCityData, CodeToText,TextToCode} from 'element-china-area-data'
    import upload from "../../../components/upload/upload";
    import cardUpload from "../../../components/upload/cardUpload";
    import TencentCaptcha from "../../../components/TencentCaptcha/TencentCaptcha";
    import {get_n_Org, getProfile, exam_reg,editContent} from "../../../request/api";
    import registerForm from "../../../components/registerForm/registerForm";
    import imgUpload from "../../../components/imgUpload/imgUpload";

    export default {
        name: "index",
        data() {
            return {
                examCityOption:[],
                stateModel: {
                    0: '机构一审驳回',
                    1: '机构一审待审',
                    2: '总部一审驳回',
                    3: '总部一审待审',
                    4: '机构二审驳回',
                    5: '机构二审待审',
                    6: '总部二审驳回',
                    7: '总部二审待审',
                    8: '全部审核通过'
                },
                selectedOptions: [],//选择后的省市区对象数组
                areaOptions: provinceAndCityData,//省市区三级联动
                oldForm:{},
                form: {},
                drawer: false,
                direction: 'rtl',
                cardOptions: [{id: 1, name: '居民身份证'}, {id: 2, name: '护照'}, {id: 3, name: '港澳台胞身份证'}],
                dialogVisible: false,
                profile: [],//个人档案
                isToExam: false,
                active: 1,
                rules: {
                    name: [
                        {required: true, message: '请输入用户名', trigger: 'blur'},
                    ],
                    last_py: [
                        {required: true, message: '请输入姓拼音', trigger: 'blur'}
                    ],
                    first_py: [
                        {required: true, message: '请输入名拼音', trigger: 'blur'}
                    ],
                    card_type: [
                        {required: true, message: '请选择证件类型', trigger: 'change'}
                    ],
                    card_id: [
                        {required: true, message: '请输入证件号码', trigger: 'blur'}
                    ],
                    birthday: [
                        {
                            required: true, message: '请输入出生年月', trigger: 'blur'
                        }
                    ],
                    address: [
                        {
                            required: true, message: '请输入家庭住址', trigger: 'blur'
                        }
                    ],
                    org_code: [
                        {required: true, message: '请输入机构代码', trigger: 'blur'}
                    ],
                    school: [
                        {required: true, message: '请输入学校名称', trigger: 'blur'}
                    ],
                    grad_time: [
                        {required: true, message: '请填写毕业时间', trigger: 'change'}
                    ],
                    hig_edu: [
                        {required: true, message: '请填写最高学历', trigger: 'blur'}
                    ],
                    major: [
                        {required: true, message: '请输入专业门类', trigger: 'blur'}
                    ],
                    com_name: [
                        {required: true, message: '请输入单位名称', trigger: 'blur'}
                    ],
                    work_duty: [
                        {required: true, message: '请输入现有职务', trigger: 'blur'}
                    ],
                    work_title: [
                        {required: true, message: '请输入现有职称', trigger: 'blur'}
                    ],
                    work_age: [
                        {required: true, message: '请填写从业年限', trigger: 'change'}
                    ],
                    course: [
                        {required: true, message: '请输入考试级别', trigger: 'blur'}
                    ],
                    exam_date: [
                        {required: true, message: '请填写考试时间', trigger: 'change'}
                    ],
                    exam_city: [
                        {required: true, message: '请填写考试城市', trigger: 'change'}
                    ],
                    is_train: [
                        {required: true, message: '请选择是否参加培训', trigger: 'change'}
                    ],
                    photo: [
                        {required: true, message: '请上传证件照', trigger: 'blur'}
                    ],
                    phone: [
                        {required: true, message: '请输入手机号码', trigger: 'blur'}
                    ],
                    code: [
                        {required: true, message: '请输入手机验证码', trigger: 'blur'}
                    ]
                },
                examForm: {
                    name: '',//姓名
                    last_py: '',//姓拼音
                    first_py: '',//名拼音
                    card_type: 1,//证件类型
                    card_id: '',//证件号码
                    birthday: '',//出生日期
                    address: '',//家庭住址
                    org: {
                        org_code: '',//机构代码
                    },
                    school: '',//毕业学校
                    grad_time: '',//毕业时间
                    hig_edu: '',//最高学历
                    major: '',//专业门类
                    com_name: '',//单位名称
                    work_duty: '',//现有职务
                    work_duty_en: '',//现有职务英文
                    work_title: '',//现有职称
                    work_age: '1',//从业年限
                    course: {
                        id: '', //考试级别,
                        name: ''
                    },
                    exam_date: '',//考试时间
                    exam_city: '',//考试城市 (薪酬管理师)
                    is_train: false,//是否参加培训 (薪酬管理师)
                    photo: "",//上传证件照片
                    sign: '',//电子签名
                    phone: '',//手机号码
                    code: '',//手机验证码
                },
                oldExamForm:[],
            }
        },
        methods: {
            getCourse(){
                courselist().then(res =>{
                    console.log('course',res)
                })
            },
            upload(photo){
              this.examForm.photo = photo;
            },
            //获取省市区
            addressChange(arr) {
                this.form.province = CodeToText[arr[0]];
                this.form.city = CodeToText[arr[1]];
            },
            //修改信息
            editContent() {
                console.log('oldForm',this.oldForm,'newForm',this.form);
                let params = {'pid':this.form.id};
                for (let item in this.oldForm){
                    if(this.form[item] !== this.oldForm[item]){
                        if(Object.prototype.toString.call(this.form[item])==='[object Object]' ){
                            continue;
                        }
                        params[item] = this.form[item];
                    }
                }
                console.log('params',params)
                editContent(params).then(res =>{
                    console.log(res);
                    this.$message({
                        type:"success",
                        message:"修改成功"
                    })
                    this.drawer = false;
                    this.getProfile();
                }).catch(err =>{
                    this.form = this.oldForm;
                    this.$message({
                        type:"error",
                        message:err.msg
                    })
                })
                console.log('submit!');
            },
            //修改信息
            updateContent(index) {
                this.oldForm = JSON.parse(JSON.stringify(this.profile[index]));
                this.form = this.profile[index];
                this.selectedOptions.push(TextToCode[this.form.province].code,TextToCode[this.form.province][this.form.city].code);
                this.drawer = true
            },
            //N次报名
            get_n_Org(params) {
                get_n_Org(params).then(res => {
                    console.log(res);
                    this.dialogVisible = false;
                    this.getProfile();
                }).catch(err => {
                    this.$message({
                        type: 'error',
                        message: err.msg
                    })
                })
            },
            //获取全部档案
            getProfile() {
                getProfile().then(res => {
                    console.log('档案信息',res);
                    this.profile = res
                })
            },
            isToExamFun(index) {
                console.log(this.profile[index]);
                this.oldExamForm = JSON.parse(JSON.stringify(this.profile[index]));
                this.examForm = this.profile[index];
                let birthday = this.examForm.card_id.substring(6, 14);
                this.examForm.birthday = birthday.slice(0, 4) + '-' + birthday.slice(4, 6) + '-' + birthday.slice(6)
                this.isToExam = true
            },
            //报考补考
            examReg() {
                // this.examForm.course.id = course_id;
                // let params = {
                //     phone :this.examForm.phone,
                //     code:this.examForm.code,
                //     name:this.examForm.name,
                //     course_id:this.examForm.course.id,
                //     org_code:this.examForm.org.org_code,
                //     exam_date:this.examForm.exam_date,
                //     exam_city:this.examForm.exam_city
                // };
                this.$refs['examForm'].validate((valid) => {
                    if (valid) {
                        this.examForm['course_id'] = this.examForm.course.id;
                        this.examForm['org_code'] = this.examForm.org.org_code;
                        // console.log(this.examForm);
                        exam_reg(this.examForm).then(res => {
                            console.log(res);
                            console.log(this.isToExam);
                            this.$message({
                                type:"success",
                                message:"提交成功"
                            })
                            this.examForm = this.oldExamForm;
                            this.isToExam = false;
                            this.getProfile();

                        }).catch(err => {
                            console.log('catch', err)
                            this.$message({
                                type: 'error',
                                message: err.msg + err.errors
                            })
                        })
                    } else {
                        this.$message({
                            type:"warning",
                            message:"请检查是否漏写字段"
                        })
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            handleClose() {
                this.dialogVisible = false
            },
            toMyExam() {
                this.examForm = this.oldExamForm;
                this.isToExam = false;
            },
            pre() {
                if (this.active-- < 2) this.active = 1
            },
            next() {
                if (this.active++ > 3) this.active = 1;
            },
            editHandleClose() {
                this.drawer = false;
            }
        },
        created(){
            this.getCourse();
        },
        mounted() {
            this.getProfile();
        },
        computed:{
            registerParams(){
                return JSON.parse(JSON.stringify(this.profile))
            }
        },
        components: {
            registerForm,
            TencentCaptcha,
            cardUpload,
            upload,
            imgUpload
        }
    }
</script>

<style>
    .text {
        font-size: 14px;
    }

    .item {
        margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
        display: table;
        content: "";
    }

    .clearfix:after {
        clear: both
    }

    .box-card {
        width: auto;
    }
</style>

<style scoped>
    .Registertext{
        margin-left: 10px;
    }
    .register-main {
        /*display: flex;*/
        /*justify-content: space-around;*/
        /*flex-wrap: wrap;*/
    }

    .model {
        /*width: 45%;*/
        margin-bottom: 20px;
    }

    .myexam-message:first-child {
        padding-top: 0px;
    }

    .myexam-message i {
        margin-right: 5px;
    }

    .myexam-message p {
        font-size: 16px;
        font-weight: 500;
        padding: 10px 0px;
        text-align: left;
    }
</style>
